package cn.edu.tsc.controller;

import cn.edu.tsc.dao.EmpDao;
import cn.edu.tsc.dao.UserDao;
import cn.edu.tsc.pojo.Emp;
import cn.edu.tsc.pojo.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


@WebServlet("/FindAllServlet")
public class FindAllServlet extends HttpServlet {

//    private static final long serialVersionUID = 1L;
//
//
//    public FindAllServlet() {
//        super();
//    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //接收数据
        request.setCharacterEncoding("utf-8");

        EmpDao empDao = new EmpDao();

        List<Emp> emps = empDao.FindAll();

        request.setAttribute("listEmp", emps);

//        response.sendRedirect("index.jsp");
        request.getRequestDispatcher("index.jsp").forward(request, response);

    }


}
